package sel.me.spring;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

import sel.me.spring.beans.TestBeanA;


public class BeanFactoryTest {

	public static void main(String[] args) throws Exception {
        ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();

        Resource[] resources = resourcePatternResolver.getResources("classpath*:spring/spring-*.xml");
        
        for (Resource resource : resources) {
            System.out.println(resource.getFilename());
            System.out.println(resource.getURL());
            System.out.println(resource.getURI());
            System.out.println("=================");
        }
        
        ClassPathResource res=new ClassPathResource("spring/spring-*.xml");
        DefaultListableBeanFactory factory=new DefaultListableBeanFactory();
        XmlBeanDefinitionReader reader=new XmlBeanDefinitionReader(factory);
        reader.loadBeanDefinitions(res);
        TestBeanA testBeanA=(TestBeanA) factory.getBean("testBeanA");
        testBeanA.testEnvironment();
        
    }
}
